unit uRel_OrdemFabricacao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, QRCtrls, jpeg, QuickRpt, ExtCtrls, DB, RLReport, DBTables,
  RLFilters, RLPDFFilter, DBClient, Grids, DBGrids;

type
  TfrmRel_OrdemFabricacao = class(TForm)
    RLReport1: TRLReport;
    Cabecalho: TRLBand;
    RLImage1: TRLImage;
    DS: TDataSource;
    Titulo: TRLBand;
    RLImage2: TRLImage;
    Detalhe: TRLBand;
    RLImage3: TRLImage;
    Rodape: TRLBand;
    RLImage4: TRLImage;
    lblTitulo: TRLLabel;
    lblSubTitulo: TRLLabel;
    RLLabel3: TRLLabel;
    RLLabel4: TRLLabel;
    lblDataAbertura: TRLLabel;
    traco1: TRLDraw;
    RLLabel6: TRLLabel;
    RLLabel7: TRLLabel;
    RLLabel8: TRLLabel;
    RLLabel9: TRLLabel;
    RLLabel10: TRLLabel;
    RLLabel12: TRLLabel;
    traco2: TRLDraw;
    RLLabel13: TRLLabel;
    RLLabel14: TRLLabel;
    RLLabel15: TRLLabel;
    RLLabel16: TRLLabel;
    lblTot1: TRLLabel;
    lblTot2: TRLLabel;
    lblUnitcMo: TRLLabel;
    lblUnitsMo: TRLLabel;
    lblSubTot: TRLLabel;
    lblMO: TRLLabel;
    lblCST: TRLLabel;
    lblPerc: TRLLabel;
    lblPeso: TRLLabel;
    lblCaixas: TRLLabel;
    lblProduzido: TRLLabel;
    lblOF: TRLLabel;
    lblLote: TRLLabel;
    lblData: TRLLabel;
    lblProduzir: TRLLabel;
    RLPDFFilter1: TRLPDFFilter;
    CDS: TClientDataSet;
    CDSproduto_Codigo: TStringField;
    CDSsaldo_Carteira: TFloatField;
    CDSSaldo_Estoque: TStringField;
    CDSQtde_Nece: TFloatField;
    CDSCusto: TFloatField;
    CDSEst_Minimo: TFloatField;
    CDSSaldo_Comprar: TFloatField;
    CDSValor_Prev: TFloatField;
    RLDBText1: TRLDBText;
    RLDBText2: TRLDBText;
    RLDBText3: TRLDBText;
    RLDBText4: TRLDBText;
    RLDBText5: TRLDBText;
    RLDBText6: TRLDBText;
    RLDBText7: TRLDBText;
    RLDBText8: TRLDBText;
    CDSPro_Nome: TStringField;
    CDSBase: TFloatField;
    CDSUnidade: TStringField;
    CDSVlrUnit: TFloatField;
    CDSQtProduzida: TFloatField;
    RLSystemInfo1: TRLSystemInfo;
    RLLabel1: TRLLabel;
    CDSTotal: TFloatField;
    CDSFase: TStringField;
    CDSMO: TFloatField;
    CDStipo: TStringField;
    CDSQtde_engenhari: TFloatField;
    procedure DetalheBeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure CDSproduto_CodigoGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure CDSQtde_engenhariGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure CDSVlrUnitGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure CDSTotalGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure CDSQtde_NeceGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure CDSQtProduzidaGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure RodapeBeforePrint(Sender: TObject; var PrintIt: Boolean);
  private
    { Private declarations }
    totPaginas: Integer;
  public
    { Public declarations }
  end;

var
  frmRel_OrdemFabricacao: TfrmRel_OrdemFabricacao;
  cont: Integer;

implementation

uses Biblio;

{$R *.dfm}

procedure TfrmRel_OrdemFabricacao.DetalheBeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
  inc(cont);
  if cont > 25 then begin
    inc(totPaginas);
    RLReport1.NewPageNeeded := True;
    RLReport1.NewPage;
    cont := 0;
  end;
end;

procedure TfrmRel_OrdemFabricacao.FormCreate(Sender: TObject);
begin
  cont := 25;
  totPaginas := 0;
end;

procedure TfrmRel_OrdemFabricacao.CDSproduto_CodigoGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := CDSproduto_Codigo.AsString;
  // Text:= alltrim(copy( CDSproduto_Codigo.AsString,4,20));
end;

procedure TfrmRel_OrdemFabricacao.CDSQtde_engenhariGetText(Sender: TField; var
  Text: string; DisplayText: Boolean);
begin
  Text := Formata_Float(CDSQtde_engenhari.AsFloat, 12, 3);
end;

procedure TfrmRel_OrdemFabricacao.CDSVlrUnitGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := Formata_Float(CDSVlrUnit.AsFloat, 12, 3);
end;

procedure TfrmRel_OrdemFabricacao.CDSTotalGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := Formata_Float(CDSTotal.AsFloat, 12, 3);
end;

procedure TfrmRel_OrdemFabricacao.CDSQtde_NeceGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := Formata_Float(CDSQtde_Nece.AsFloat, 12, 3);
end;

procedure TfrmRel_OrdemFabricacao.CDSQtProduzidaGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  Text := Formata_Float(CDSQtProduzida.AsFloat, 12, 3);
end;

procedure TfrmRel_OrdemFabricacao.RodapeBeforePrint(Sender: TObject;
  var PrintIt: Boolean);
begin
  PrintIt := totPaginas = RLReport1.PageNumber;
end;

end.

